[PATCH] h266parser: Validate tile index bounds in picture partition parsing
authorCarlos Bentzen <cadubentzen@igalia.com>
Fri, 20 Feb 2026 16:10:04 +0000 (17:10 +0100)
committerMoritz Mühlenhoff <jmm@debian.org>
Mon, 30 Mar 2026 21:57:55 +0000 (23:57 +0200)
Gbp-Pq: Name CVE-2026-3084.patch

gst-libs/gst/codecparsers/gsth266parser.c

index 0f52e5fa4eaec6ffb0cd4a7d0b27f180ecf46227..3da42e9492de588eb88343ba1a9eaa7e7ac29cc5 100644 (file)
@@ -3618,15 +3618,28 @@ gst_h266_parser_parse_picture_partition (GstH266SPS * sps,
               goto error;
             }
 
-            tile_idx += pps->tile_idx_delta_val[i];
+            gint new_tile_idx = (gint) tile_idx + pps->tile_idx_delta_val[i];
+            if (new_tile_idx < 0 ||
+                new_tile_idx >= (gint) pps->num_tiles_in_pic) {
+              GST_WARNING ("tile_idx %d out of bounds.", new_tile_idx);
+              goto error;
+            }
+            tile_idx = new_tile_idx;
           } else {
             pps->tile_idx_delta_val[i] = 0;
 
-            tile_idx += pps->slice_width_in_tiles_minus1[i] + 1;
-            if (tile_idx % pps->num_tile_columns == 0) {
-              tile_idx += pps->slice_height_in_tiles_minus1[i] *
+            gint new_tile_idx = (gint) tile_idx +
+                pps->slice_width_in_tiles_minus1[i] + 1;
+            if (new_tile_idx % pps->num_tile_columns == 0) {
+              new_tile_idx += pps->slice_height_in_tiles_minus1[i] *
                   pps->num_tile_columns;
             }
+            if (new_tile_idx < 0 ||
+                new_tile_idx >= (gint) pps->num_tiles_in_pic) {
+              GST_WARNING ("tile_idx %d out of bounds.", new_tile_idx);
+              goto error;
+            }
+            tile_idx = new_tile_idx;
           }
         }
       }